package com.ftd.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.ftd.DBConnection.DBConnection;
import com.ftd.model.Ebook;
import com.ftd.model.Mark;
import com.ftd.viewmodel.ApiResult;
import com.ftd.viewmodel.MapResult;
import org.apache.http.Consts;
import org.apache.http.HttpResponse;
import org.apache.http.client.ResponseHandler;
import org.apache.http.client.fluent.Request;
import org.apache.http.util.EntityUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by apple on 16/8/1.
 */
@RestController
public class MarkViewDetailController {
    @RequestMapping(value = "getMarkDetailJson")
    public ApiResult getMarkDetailJson(String index) {

        ArrayList list = (ArrayList)DBConnection.select2("markTable_2");

        MapResult mapResult = new MapResult();

        for (int i = 0; i < list.size();i++) {
            Mark mark = (Mark)list.get(i);
            if (mark.getTag().equals(index)){
                mapResult.put("title", mark.getmTitle());
                mapResult.put("imageUrl", mark.getmImageUrl());
                mapResult.put("type", mark.getmType());
                mapResult.put("reading", mark.getmCount());
                mapResult.put("comment",mark.getComment());
                mapResult.put("filmUrl",mark.getFilmUrl());
                break;
            }
        }

        return mapResult;
    }
}
